import java.util.Scanner;

class UserNameException extends RuntimeException{
    public UserNameException(String message) {
        super(message);
    }
}
class PasswordException extends RuntimeException{
    public PasswordException(String message) {
        super(message);
    }
}
public class TestClass {
    private String uerName = "admin";
    private String password = "12345";
    public void loginInfo(String uerName,String password) throws UserNameException,PasswordException {
        if(!this.uerName.equals(uerName)){
            throw new UserNameException("用户名异常");
        }
        if(!this.password.equals(password)) {
            throw new PasswordException("密码异常");
        }
        if(this.uerName.equals(uerName)||this.password.equals(password)) {
            System.out.println("登录成功");
        }
    }
    public static void main(String[] args) {
        TestClass test = new TestClass();
        System.out.println("请输入用户名：");
        Scanner scan = new Scanner(System.in);
        String userName = scan.nextLine();
        System.out.println("请输入密码");
        String password = scan.nextLine();
        try {
            test.loginInfo(userName,password);
        } catch (UserNameException e){
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}
